#include<bits/stdc++.h>
using namespace std;

int n;

int f[1000005];

void init() {
    for(int i = 1; i <= n; i++)
        f[i] = i;
}

int find_set(int x) {
    if(f[x] != x)	f[x] = find_set(f[x]);
    return f[x];
}

void union_set(int x, int y) {
    x = find_set(x);
    y = find_set(y);
    f[x] = f[y];
}

signed main() {
//	system("start https://www.lanqiao.cn/problems/1085/learning/");

    cin >> n;

    init();

    int x;
    for(int i = 1; i <= n; i++) {
        cin >> x;
        if(f[i] != x) {
            union_set(f[i], f[x]);
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++)
        if(f[i] == i)
            ans++;
    cout << ans;

    return 0;
}

